package com.david.equipment.controller;

import com.david.common.utils.PageResult;
import com.david.equipment.pojo.entity.DeviceEntity;
import com.david.equipment.pojo.vo.DeviceVO;
import com.david.equipment.service.DeviceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import static com.david.common.utils.ResultUtils.success;

@RestController
@RequestMapping("/equipment/device")
@Slf4j
public class DeviceController {

    @Autowired
    private DeviceService deviceService;

    @PutMapping
    public ResponseEntity<Object> addDevice(@RequestBody DeviceEntity device) {
        log.info("新增设备：{}", device);
        deviceService.addDevice(device);
        return success(true, "新增成功");
    }

    @PostMapping
    public ResponseEntity<Object> getDeviceList(@RequestBody DeviceVO deviceVO) {
        log.info("获取设备列表：{}",deviceVO);
        PageResult deviceList = deviceService.getList(deviceVO);
        return success(true,deviceList);
    }
}
